Recreate plots as ploty interactive, and host them
#library(ggplot2)
datnew = read.table("/Users/zskurian/Documents/JHU Grad School/DS4BME/HW3/classInterests.txt", header=TRUE)
m = ggplot(datnew,aes(x=Year))
m = m + geom_bar()
k = ggplot(datnew,aes(x=Program))
k = k + geom_bar()
ggplotly(k)
library(ggmosaic)
j = ggplot(data = datnew, mapping = aes(x=Program,y=Year))
j = j + geom_mosaic(aes(x=product(Year,Program), fill=Year))
ggplotly(j)
headers3 = read.csv("/Users/zskurian/Documents/JHU Grad School/DS4BME/HW3/healthcare.csv", skip = 1, header = F, nrows = 1, as.is = T)
df3 = read.csv("/Users/zskurian/Documents/JHU Grad School/DS4BME/HW3/healthcare.csv", header = F)
colnames(df3)= headers3
tempDF <- df3
tempDF[] <- lapply(df3, as.character)
colnames(df3) <- tempDF[1, ]
df3 <- df3[-1 ,]
tempDF <- NULL
#make the third row the headers
names(df3) <- as.matrix(df3[1, ])
df3 <- df3[-1, ]
df3[] <- lapply(df3, function(x) type.convert(as.character(x)))
#do it again
names(df3) <- as.matrix(df3[1, ])
df3 <- df3[-1, ]
df3[] <- lapply(df3, function(x) type.convert(as.character(x)))
#
#healthtibble <- tibble(df)
longerdf3 <- pivot_longer(df3,cols = -Location, names_to="year",values_to="value")
#Make long format
#remove the beginning and end
#make first row the column headers
#group by Location
longerdf3 = longerdf3[1:1248,]
h = ggplot(longerdf3,aes(x=year,y=value,group=Location,color=Location)) + geom_line()
h = h + theme(axis.text.x = element_text(angle = 90))
h = h + theme(axis.text.y = element_text(angle = 75))
ggplotly(h)
#df = read.csv("healthcare.csv", header = F)
#put the long dataframe from problem 5 into a pivot longer
#longerdf10 %>% pivot_longer(df3)
longerdf10 = longerdf3
longerdf11 <- longerdf10 %>% mutate(value=as.double(value))
meanlongerdf11 <- longerdf11 %>% group_by(Location) %>% mutate(Meanspend = mean(value))
meanplot = ggplot(meanlongerdf11,color=Location) + geom_bar(aes(x=Location,y=Meanspend),stat="identity")
meanplot = meanplot + theme(axis.text.x = element_text(angle = 80,hjust=1))
ggplotly(meanplot)